//
//  TenCollectionViewCell.m
//  UI_元旦豆瓣小集合
//
//  Created by dllo on 16/1/7.
//  Copyright © 2016年 lanou3g. All rights reserved.
//

#import "TenCollectionViewCell.h"
#import "TenModel.h"
#import "UIImageView+WebCache.h"



@interface TenCollectionViewCell ()

@property (nonatomic, retain) UIImageView *images;
@property (nonatomic, retain) UILabel *title;

@end



@implementation TenCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createCell];
    }return self;
}
- (void)dealloc {
    [_images release];
    [_title release];
    [super dealloc];
}
- (void)setModel:(TenModel *)model {
    if (_model != model) {
        [_model release];
        _model = [model retain];
        [self fuzhi];
        
    }
}
- (void)fuzhi{
    
    [_images sd_setImageWithURL:[NSURL URLWithString:_model.images[@"large"]]];
    
     _title.text = _model.title;
    _title.textAlignment = NSTextAlignmentCenter;
}



- (void)createCell {
    self.images = [[UIImageView alloc] init];
    [self.contentView addSubview:_images];
    [_images release];
    
    self.title = [[UILabel alloc] init];
    [self.contentView addSubview:_title];
    [_title release];
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    _images.frame = CGRectMake(0, 0, layoutAttributes.frame.size.width, layoutAttributes.frame.size.height);
    _images.backgroundColor = [UIColor orangeColor];
    _title.frame = CGRectMake(0, layoutAttributes.size.height + 10, layoutAttributes.frame.size.width, 30);
    _title.backgroundColor = [UIColor whiteColor];
}


@end
